<template>
	<view class="wrap">
		<view class="steps-box">
			<u-steps :current="current" dot activeColor="#e16b8c">
				<u-steps-item title="完善资料"></u-steps-item>
				<u-steps-item title="择偶标准"></u-steps-item>
				<u-steps-item title="联系方式"></u-steps-item>
				<u-steps-item title="完成发布"></u-steps-item>
			</u-steps>
		</view>
		<view class="set-list" v-if="current==0">
			<view class="set-list-line">
				<u--text align="left" text="头像"></u--text>
				<view class="right-box u-flex">
					<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
						<image class="head-img" :src="avatar"></image>
					</button>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="set-list-line">
				<u--text align="left" text="昵称"></u--text>
				<view class="right-box u-flex">
					<input placeholder="昵称" type="nickname" v-model="nickname" placeholder-class="placeholderClass" />
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="set-list-line" @click="ageShow = true">
				<u--text align="left" text="年龄"></u--text>
				<view class="right-box u-flex">
					<text>{{age}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="set-list-line">
				<u--text align="left" text="性别"></u--text>
				<view class="right-box u-flex">
					<ul class="tabs-ul">
						<li class="tabs-ul-li" :class="{active:item.id==activeTab}" v-for="(item, index) in tabs"
							:key="index" @click="changeTab(item.id)">{{ item.title }}</li>
					</ul>
				</view>
			</view>
			<view class="set-list-line" @click="show = true">
				<u--text align="left" text="身高"></u--text>
				<view class="right-box u-flex">
					<text>{{height}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="set-list-line" @click="show = true">
				<u--text align="left" text="常住地"></u--text>
				<view class="right-box u-flex">
					<text>{{height}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="set-list-line" @click="show = true">
				<u--text align="left" text="户籍地"></u--text>
				<view class="right-box u-flex">
					<text>{{height}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<u--textarea placeholder="请填写个性介绍,500字以内" height="100" style="margin-top: 20upx;"></u--textarea>
			<view class="tips">温馨提示:个性介绍是征婚的重要环节,详细介绍兴趣爱好，性格特征,工作情况及家庭情况,有助于提高成功率。</view>
		</view>
		<view class="set-list" v-if="current==1">
			<view class="set-list-line" @click="show = true">
				<u--text align="left" text="年龄范围"></u--text>
				<view class="right-box u-flex">
					<text>{{height}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<u--textarea placeholder="请填写择偶标准,500字以内" height="100" style="margin-top: 20upx;"></u--textarea>
			<view class="tips">提示:正确合理的择偶定位，是征婚成功的最大保障，尽量放宽择偶标准，婚姻最后都是拼的人品</view>
		</view>
		<view class="set-list" v-if="current==2">
			<view class="contacts-cont">
				<view class="contacts-item u-flex u-flex-between">
					<view class="telnum">已绑定手机号:19936603166</view>
				</view>
				<view class="contacts-item u-flex u-flex-between">
					<view class="telnum">公开联系</view>
					<u-switch v-model="value" @change="change" active-color="#e16b8c"></u-switch>
				</view>
			</view>
			<view class="tips">温馨提示:以上设置以后可以在"我的-联系方式"中修改</view>
		</view>
		<u-picker :show="show" :columns="columns" @confirm="confirm"></u-picker>
		<u-picker :show="ageShow" :columns="ageList" @confirm="aegConfirm"></u-picker>
		<view class="button">
			<block v-if="current==0">
				<u-button size="nomal" color="#e16b8c" text="下一步" @tap="next()"></u-button>
			</block>
			<view class="flexWrap"  v-if="current==1">
				<u-button size="nomal" color="#e16b8c" text="上一步" :plain="true" @tap="pre()" style="width: 300upx;"></u-button>
				<u-button size="nomal" color="#e16b8c" text="下一步" @tap="next()" 	style="width: 300upx;"></u-button>
			</view>
			<view class="flexWrap"  v-if="current==2">
				<u-button size="nomal" color="#e16b8c" text="上一步" :plain="true" @tap="pre()" style="width: 300upx;"></u-button>
				<u-button size="nomal" color="#e16b8c" text="确认并发布" style="width: 300upx;" @tap="confirmInfo()"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				avatar: "https://cdn.uviewui.com/uview/album/1.jpg",
				nickname: "",
				activeTab: 1, // 当前活跃的选项卡ID
				tabs: [{
						id: '1',
						title: '男'
					},
					{
						id: '2',
						title: '女'
					},
				],
				show: false,
				columns: [
					['中国', '美国', '日本']
				],
				height:"",
				current:0,
				value: false,
				ageShow:false,
				age:"",
				ageList:[
					['18','19','20']
				]
			}
		},
		methods: {
			onChooseAvatar(e) {
				this.avatar = e.detail.avatarUrl
				this.uploadFilePromise(e.detail.avatarUrl)
			},
			changeTab(id) {
				this.activeTab = id;
			},
			change(e) {
				console.log('change', e);
			},
			// 回调参数为包含columnIndex、value、values
			confirm(e) {
				this.show = false
				this.height=e.value[0]
			},
			aegConfirm(e){
				this.ageShow = false
				this.age=e.value[0]
			},
			next(){
				if(this.current==0){
					if(!this.nickname){
						this.toast('请填写昵称');
						return;
					}
					if(!this.age){
						this.toast('请选择年龄');
						return;
					}
				}
				this.current++
			},
			pre(){
				this.current--
			},
			confirmInfo(){
				let requestData={
					nickname:this.nickname,
					age:this.age
				}
				
			}
		}
	}
</script>

<style lang="less">
	.steps-box{
		background: #FFFFFF;
	}
	.wrap {
		display: flex;
		flex-direction: column;
		background: #f4f4f4;
	}
	.tips{
		font-size:24upx;
		margin: 30upx 0;
		line-height: 40upx;
	}
	button::after {
		border: none;
	}

	button {
		margin-left: 0;
		margin-right: 0;
		padding-left: 0;
		padding-right: 0;
		line-height: 1;
		color: #FFFFFF;
		font-size: 28rpx;
		background: none;
		width: 100%;
		border: none;
	}

	.set-list {
		display: flex;
		flex-direction: column;
		padding: 0 30upx;
		background: #fff;

		.set-list-line {
			display: flex;
			flex-direction: row;
			padding: 30upx 0;
			background: #fff;
			border-bottom: 1rpx solid #E1E5ED;

			.right-box {
				font-size: 28upx;
				input {
					font-size: 28upx;
					text-align: right;
				}
			}
		}
	}

	.tabs-ul {
		display: flex;
		flex-direction: row;
		list-style: none;
		height: 65rpx;
		line-height: 65rpx;
		text-align: center;
		margin: 0;
		padding: 0;

		.tabs-ul-li {
			width: 100upx;
			height: 40upx;
			line-height: 40upx;
			text-align: center;
			border-radius: 50upx;
			font-size: 28upx;
		}

		.active {
			background-color: #e16b8c;
			color: #fff;
		}
	}

	.avatar-wrapper {
		border: 1upx solid #eee;
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		margin: auto;
	}

	.head-img {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		overflow: hidden;
	}

	.button {
		background: #fff;
		padding: 80upx 40upx 0upx 40upx;
		position: fixed;
		bottom: 30upx;
		left: 0;
		right: 0;
	}
	.contacts-cont {
		padding: 0 30upx;
	
		.contacts-item {
			align-items: center;
			border-bottom: 1rpx solid #eee;
			padding: 30upx 0;
	
			.telnum {
				font-size: 28upx;
			}
	
			.change-btn {
				height: 50upx;
				line-height: 50upx;
				width: 100upx;
				text-align: center;
				background: #e16b8c;
				color: #fff;
				font-size: 28upx;
				border-radius: 10upx;
			}
	
			input {
				text-align: right;
				font-size: 28upx;
			}
	
			.save-btn{
				margin-top: 20upx;
			}
		}
	}
</style>